package com.bdqn.t320.service;

import com.bdqn.t320.dao.UserDao;
import com.bdqn.t320.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//@Component
@Service("userService2")
public class UserServiceImp implements UserService {
    //private UserDao userDao = new UserDaoImp();

    //Resource  默认是按照name匹配,然后在按照类型匹配
    //Autowired   默认是按照类型匹配,然后在按照name匹配

    //spring注解
    //@Autowired
    //jdk, JSR规范
    //@Resource(name = "userDao")
    @Autowired
    @Qualifier("userDao")
    private UserDao userDao3;

    public void setUserDao(UserDao userDao3) {
        this.userDao3 = userDao3;
    }
    //aop的目的是从系统中分离出切面，独立于业务逻辑实现在程序执行时织入程序中运行

    public int saveService(User user) {
        //System.out.println(1/0);
        return userDao3.add(user);
    }

    public void log(){
        System.out.println("记录用户增加的service操作时间");
    }

    public void print(){
        System.out.println("aaaaaaaaaaaaaaaaaa");
    }
}
